// Copyright 2014 Google Inc. All Rights Reserved.

#include <errno.h>
#include <irt_syscalls.h>
#include <unistd.h>

int readlink(const char *path, char *buf, size_t bufsize) {
  if (__nacl_irt_readlink) {
    size_t nread;
    int result = __nacl_irt_readlink(path, buf, bufsize, &nread);

    if (result != 0) {
      errno = result;
      return -1;
    }

    return (int) nread;
  }

  errno = ENOSYS;
  return -1;
}

